package com.perfect.controller;


import com.perfect.model.Stock;
import com.perfect.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/oms-stock")
public class StockController {

    @Autowired
    private StockService stockService;




    @RequestMapping("/reduct")
    public String reduct(@RequestHeader(name = "aaaaa") String header, String id){

        // 模拟长时间业务
        stockService.reduct(1L);
        return "扣减库存成功:" + id;
    }

    @RequestMapping("/list")
    public List<Stock> list(){

        return  stockService.queryList();
    }


    /**
     * feign 原生注解使用示例
     *
     * @return
     */
    @RequestMapping("/contractTest")
    public void contractTest() {
        System.out.println("测试使用feign 原生注解");
    }


}
